#include <stdlib.h>
#include <stdio.h>
#include <nds.h>

// common headers
#include "common.h"		// global

// local headers
#include "ini.h"
#include "list.h"

#include "main.h"

#define _VERSION_INT MAKE_VERSION(0, 0, 2, STATE_BETA, 1)
char _VERSION_STR[VERSION_STR_MAX_LEN+1];
char *_exts[]={ ".ini" };
sEL exts={
	.exts=_exts,
	.extnum=sizeof(_exts)/sizeof(*_exts)
};

// config interface
sCInterface sCI = {
	.open=open,

	.get_first=il_getFirst,
	.get_next=il_getNext,

	.get_string=il_get,
	.get_bool=get_bool,
	.get_integer=get_integer,
	.get_float=get_float,

	.set_string=set_string,
	.set_bool=set_bool,
	.set_integer=set_integer,
	.set_float=set_float,

	.unset=unset,

	.save=save,
	.close=close
};

int init() {
	std->sprintf(_VERSION_STR, VERSION_FORMAT, VERSION_ARGS(_VERSION_INT));	// make version str

	return 0;
}

u32 query(u32 query) {
	switch(query) {
	case QUERY_NAME:		// library name
		return (u32)"libini";
	case QUERY_VERSION_INT:	// library integer version
		return (u32)_VERSION_INT;
	case QUERY_VERSION_STR:	// library string version
		return (u32)_VERSION_STR;
	case QUERY_AUTHOR:		// library author
		return (u32)"Ludo6431";
	case QUERY_FILEEXT:		// file extensions
		return (u32)&exts;
	case QUERY_ID:			// library identifier
		return ID_LIBRARY_CONFIG;
	case QUERY_FSTRUCT:		// library functions structure
		return (u32)&sCI;
	default:
		return 0;
	}
}

void deinit() {
}

